# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=urllib3
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.25.9
pkgrel=1
pkgdesc="HTTP library with thread-safe connection pooling and file post support (mingw-w64)"
url='https://github.com/urllib3/urllib3'
license=('MIT')
arch=('any')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-certifi"
         "${MINGW_PACKAGE_PREFIX}-python-idna")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-ndg-httpsclient"
             "${MINGW_PACKAGE_PREFIX}-python-pyasn1"
             "${MINGW_PACKAGE_PREFIX}-python-pyopenssl"
             #"${MINGW_PACKAGE_PREFIX}-python-pysocks"
             "${MINGW_PACKAGE_PREFIX}-python-mock")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-nose"
              "${MINGW_PACKAGE_PREFIX}-python-tornado"
              "${MINGW_PACKAGE_PREFIX}-python-coverage"
              "${MINGW_PACKAGE_PREFIX}-python-psutil")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/urllib3/urllib3/archive/${pkgver}.tar.gz")
sha256sums=('1f1bef30176d8361ba8ae0728316e76f5ec8fc1f336c5352165211b2cb0a53f7')

prepare() {
  cd ${srcdir}
  cp -r ${_realname}-${pkgver} python-build-${CARCH}
}

build() {
  cd "${srcdir}"
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd ${srcdir}/python-build-${CARCH}
  ${MINGW_PREFIX}/bin/python setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}"

  install -D -m644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}"/share/licenses/python-${_realname}/LICENSE.txt
}
